package com.example.myapp;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class ContactDetailActivity extends AppCompatActivity {

    private ImageView contactImage;
    private TextView nicknameText, realNameText, addressText, phoneText;

    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_contact_detail);

        // 初始化UI组件
        contactImage = findViewById(R.id.contactDetailImage);
        nicknameText = findViewById(R.id.nicknameText);
        realNameText = findViewById(R.id.realNameText);
        addressText = findViewById(R.id.addressText);
        phoneText = findViewById(R.id.phoneText);

        // 获取传递过来的数据
        Intent intent = getIntent();
        String nickname = intent.getStringExtra("nickname");
        String realName = intent.getStringExtra("realName");
        String address = intent.getStringExtra("address");
        String phone = intent.getStringExtra("phone");
        int imageResId = intent.getIntExtra("imageResId", -1);

        // 填充数据
        contactImage.setImageResource(imageResId);
        nicknameText.setText(nickname);
        realNameText.setText("姓名：" + realName);
        addressText.setText("住址：" + address);
        phoneText.setText("联系方式：" + phone);
    }
}
